<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %> 
<%@ page import="data.EditarCursosGateway" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="arivp89.css" media="screen" />
        <title>Editar Cursos</title>
    </head>
    <body>
    <%
        EditarCursosGateway gw = new EditarCursosGateway();
        ResultSet rs = gw.obtenerCurso(request.getSession().getAttribute("Sigla").toString());
        
    %>
        <html:form action="/EditarCursos" method="post">
            <h1>Editar Curso</h1>
        <table border="0" width="100" cellspacing="10" cellpadding="5">
            <% if(rs.next()){ %>
            <tbody>
                <tr>
                    <td>Sigla</td>
                    <td><% out.println(request.getSession().getAttribute("Sigla").toString()); %></td>
                    <td>Contenido actual:</td>
                </tr>
                <tr>
                    <td>Nombre del curso</td>
                    <td><input type="text" name="nombre" value="" size="50" /></td>
                    <td> <% out.println(rs.getString(1)); %></td>
                </tr>
                <tr>
                    <td>Creditos</td>
                    <td><input type="text" name="creditos" value="" size="50" /></td>
                    <td> <% out.println(rs.getString(2)); %></td>
                </tr>
                <tr>
                    <td>Requisitos</td>
                    <td>
                        <select name="r1" size="1">
                            <option value="-">-</option>
                        <%  
                        rs = gw.obtenerCursos();
                        String opcion;
                        try   
                        {  
                           while(rs.next()){   
                                opcion = rs.getString(1);    
                        %>  
                            <option value=<%=opcion%>><%=opcion%></option>  
                        <%   
                                    }  
                        }  
                        catch(Exception e)  
                        {  
                          out.println(e);  
                        }  

                        %>   <br>
                        </select> 
                        <select name="r2" size="1">
                            <option value="-">-</option>
                        <%  
                        rs = gw.obtenerCursos();
                        try   
                        {  
                           while(rs.next()){   
                                opcion = rs.getString(1);    
                        %>  
                            <option value=<%=opcion%>><%=opcion%></option>  
                        <%   
                                    }  
                        }  
                        catch(Exception e)  
                        {  
                          out.println(e);  
                        }  

                        %>   <br>
                        </select> 
                        <select name="r3" size="1">
                            <option value="-">-</option>
                        <%  
                        rs = gw.obtenerCursos();
                        try   
                        {  
                           while(rs.next()){   
                                opcion = rs.getString(1);    
                        %>  
                            <option value=<%=opcion%>><%=opcion%></option>  
                        <%   
                                    }  
                        }  
                        catch(Exception e)  
                        {  
                          out.println(e);  
                        }  

                        %>   <br>
                        </select> 
                    </td>
                    <td> <% out.println(gw.obtenerRequisitos(request.getSession().getAttribute("Sigla").toString())); %></td>
                </tr>
            </tbody>
            <% } %>
        </table><br>
        <input type="submit" value="Guardar Cambios" /><html:errors />
        </html:form>
        <br><br>
        <html:link page="/EscogerCursoEditar.jsp"><- Atrás</html:link>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <div id="bottom">
            Creado por: Alejandro Rivera, Franklin Alfaro. ECCI, UCR.
            <br>
        </div>
    </body>
</html>
